<div class="layuimini-main"  id="admin-add">

    <div class="layui-form layuimini-form ">
        <div class="layui-form-item">
            <label class="layui-form-label required">用户名</label>
            <div class="layui-input-block">
                <input type="text" autocomplete='off' name="UserName" lay-verify="required" lay-reqtext="用户名不能为空" placeholder="请输入用户名" value="" class="layui-input">
                <tip>填写自己管理账号的名称。</tip>
            </div>
        </div>
		
        <div class="layui-form-item">
            <label class="layui-form-label required">身份</label>
            <div class="layui-input-block">
                <input type="radio" id="adminType1" name="Role" value="Admin" title="管理员" checked="">
                <input type="radio" id="adminType2" name="Role" value="User" title="操作员">
            </div>
        </div>
		<div class="layui-form-item">
			<label class="layui-form-label">登录密码：</label>
			<div class="layui-input-block">
				<input type="password" autocomplete='off' name="UserPassword" required lay-verify="required" lay-reqtext="登录密码不能为空" placeholder="请输入密码" class="layui-input">
			</div>
	    </div>
        <div class="layui-form-item">
            <label class="layui-form-label required">手机</label>
            <div class="layui-input-block">
                <input type="number" name="Phone" lay-verify="required" lay-reqtext="手机不能为空" placeholder="请输入手机" value="" class="layui-input">
            </div>
        </div>
        

        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn layui-btn-normal" lay-submit lay-filter="saveBtn">确认保存</button>
            </div>
        </div>
    </div><br />
</div>
<script>

    layui.use(['form', 'table', 'faceAPI'], function () {
        var form = layui.form,
            layer = layui.layer,
            table = layui.table,
            $ = layui.$;
        var faceAPI = layui.faceAPI;
        /**
         * 初始化表单，要加上，不然刷新部分组件可能会不加载
         */
        form.render();

        // 当前弹出层，防止ID被覆盖
        var parentIndex = layer.index;

        faceAPI.AdminAddPageResult = null;

        //监听提交
        form.on('submit(saveBtn)', function (data) {
            faceAPI.Ajax({
                type: 'Post',
                data: data.field,
                url: '/api/User/Add',
                success: function (result) {
                    if (result.result == false) {
                        layer.alert(result.error, { icon: 2 });

                    }
                    else {
                        faceAPI.AdminAddPageResult = result;
                        layer.close(parentIndex);
                    }

                }
            });


            return false;
        });
       
    });

</script>